﻿/*common JavaScript Function  | JQ Function 
author:vixony
CDate:20140606
Version:2.0*/
//CommonFunction
document.execCommand("BackgroundImageCache", false, true);
document.ondragstart = function () { return false; };
window.onerror = killErrors;
function killErrors() { return true; }
$.extend({
   win: function () {
        var _self = this, winH, winW, vxw = window, vxd = document, vxe = vxd.documentElement, vxg = vxd.getElementsByTagName('body')[0];
        winW = vxw.innerWidth || vxe.clientWidth || vxg.clientWidth;
        winH = vxw.innerHeight || vxe.clientHeight || vxg.clientHeight;
        return { w: winW, h: winH };
     }
   , mousePos: function (e) {
        var x, y;
        var e = e || window.event;
        return {
            x: e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft,
            y: e.clientY + document.body.scrollTop + document.documentElement.scrollTop,
            p: e.clientX
        };
     }
   , vxRandomStr: function () { return "EMwebUI" + ("" + Math.random()).replace(/\D/g, "") }
   , getQueryString: function (name) {
           var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
           var r = window.location.search.substr(1).match(reg);
           if (r != null) return unescape(r[2]); return null;
     }
   , fobidSelect: function (fbx) {//fbx为dom元素
            
        if (typeof (fbx.onselectstart) != "undefined") {
                //IE下禁止元素被选取        
            fbx.onselectstart = new Function("return false");
            } else {
                //firefox下禁止元素被选取的变通办法        
            fbx.onmousedown = new Function("return false");
            fbx.onmouseup = new Function("return true");
            } 
        }
   , copyToClipBoard: function (copyBx) {
        var clipBoardContent = '', selTxtCont,
            newsZhengWen = copyBx.innerText;
        newsZhengWen = (newsZhengWen == null) ? "" : newsZhengWen;
        if (document.all) {
            selTxtCont = document.selection.createRange().text;
        } else {
            selTxtCont = document.getSelection();
        }
        clipBoardContent += "" + selTxtCont + "";
        clipBoardContent = (clipBoardContent == "") ? newsZhengWen : clipBoardContent;
        if (window.clipboardData) { window.clipboardData.clearData();}
        window.clipboardData.setData("Text", clipBoardContent);
    }
});

//cookies
!function (a) { "function" == typeof define && define.amd ? define(["jquery"], a) : a(jQuery) }(function (a) { function c(a) { return e.raw ? a : decodeURIComponent(a.replace(b, " ")) } function d(a) { 0 === a.indexOf('"') && (a = a.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, "\\")), a = c(a); try { return e.json ? JSON.parse(a) : a } catch (b) { } } var b = /\+/g, e = a.cookie = function (b, f, g) { var h, i, j, k, l, m, n, o, p; if (void 0 !== f) return g = a.extend({}, e.defaults, g), "number" == typeof g.expires && (h = g.expires, i = g.expires = new Date, i.setDate(i.getDate() + h)), f = e.json ? JSON.stringify(f) : String(f), document.cookie = [e.raw ? b : encodeURIComponent(b), "=", e.raw ? f : encodeURIComponent(f), g.expires ? "; expires=" + g.expires.toUTCString() : "", g.path ? "; path=" + g.path : "", g.domain ? "; domain=" + g.domain : "", g.secure ? "; secure" : ""].join(""); for (j = document.cookie.split("; "), k = b ? void 0 : {}, l = 0, m = j.length; m > l; l++) { if (n = j[l].split("="), o = c(n.shift()), p = n.join("="), b && b === o) { k = d(p); break } b || (k[o] = d(p)) } return k }; e.defaults = {}, a.removeCookie = function (b, c) { return void 0 !== a.cookie(b) ? (a.cookie(b, "", a.extend({}, c, { expires: -1 })), !0) : !1 } });
/*! Copyright (c) 2013 Brandon Aaron mousewheel Version: 3.1.11 Requires: jQuery 1.2.2+*/
!function (a) { "function" == typeof define && define.amd ? define(["jquery"], a) : "object" == typeof exports ? module.exports = a : a(jQuery) }(function (a) { function b(b) { var g = b || window.event, h = i.call(arguments, 1), j = 0, l = 0, m = 0, n = 0, o = 0, p = 0; if (b = a.event.fix(g), b.type = "mousewheel", "detail" in g && (m = -1 * g.detail), "wheelDelta" in g && (m = g.wheelDelta), "wheelDeltaY" in g && (m = g.wheelDeltaY), "wheelDeltaX" in g && (l = -1 * g.wheelDeltaX), "axis" in g && g.axis === g.HORIZONTAL_AXIS && (l = -1 * m, m = 0), j = 0 === m ? l : m, "deltaY" in g && (m = -1 * g.deltaY, j = m), "deltaX" in g && (l = g.deltaX, 0 === m && (j = -1 * l)), 0 !== m || 0 !== l) { if (1 === g.deltaMode) { var q = a.data(this, "mousewheel-line-height"); j *= q, m *= q, l *= q } else if (2 === g.deltaMode) { var r = a.data(this, "mousewheel-page-height"); j *= r, m *= r, l *= r } if (n = Math.max(Math.abs(m), Math.abs(l)), (!f || f > n) && (f = n, d(g, n) && (f /= 40)), d(g, n) && (j /= 40, l /= 40, m /= 40), j = Math[j >= 1 ? "floor" : "ceil"](j / f), l = Math[l >= 1 ? "floor" : "ceil"](l / f), m = Math[m >= 1 ? "floor" : "ceil"](m / f), k.settings.normalizeOffset && this.getBoundingClientRect) { var s = this.getBoundingClientRect(); o = b.clientX - s.left, p = b.clientY - s.top } return b.deltaX = l, b.deltaY = m, b.deltaFactor = f, b.offsetX = o, b.offsetY = p, b.deltaMode = 0, h.unshift(b, j, l, m), e && clearTimeout(e), e = setTimeout(c, 200), (a.event.dispatch || a.event.handle).apply(this, h) } } function c() { f = null } function d(a, b) { return k.settings.adjustOldDeltas && "mousewheel" === a.type && b % 120 === 0 } var e, f, g = ["wheel", "mousewheel", "DOMMouseScroll", "MozMousePixelScroll"], h = "onwheel" in document || document.documentMode >= 9 ? ["wheel"] : ["mousewheel", "DomMouseScroll", "MozMousePixelScroll"], i = Array.prototype.slice; if (a.event.fixHooks) for (var j = g.length; j;) a.event.fixHooks[g[--j]] = a.event.mouseHooks; var k = a.event.special.mousewheel = { version: "3.1.11", setup: function () { if (this.addEventListener) for (var c = h.length; c;) this.addEventListener(h[--c], b, !1); else this.onmousewheel = b; a.data(this, "mousewheel-line-height", k.getLineHeight(this)), a.data(this, "mousewheel-page-height", k.getPageHeight(this)) }, teardown: function () { if (this.removeEventListener) for (var c = h.length; c;) this.removeEventListener(h[--c], b, !1); else this.onmousewheel = null; a.removeData(this, "mousewheel-line-height"), a.removeData(this, "mousewheel-page-height") }, getLineHeight: function (b) { var c = a(b)["offsetParent" in a.fn ? "offsetParent" : "parent"](); return c.length || (c = a("body")), parseInt(c.css("fontSize"), 10) }, getPageHeight: function (b) { return a(b).height() }, settings: { adjustOldDeltas: !0, normalizeOffset: !0 } }; a.fn.extend({ mousewheel: function (a) { return a ? this.bind("mousewheel", a) : this.trigger("mousewheel") }, unmousewheel: function (a) { return this.unbind("mousewheel", a) } }) });
/*Dragdrop*/
var Dragdrop = function (window) {
    var doc = window.document;
    var E = {
        on: function (el, type, fn) {
            el.addEventListener ?
				el.addEventListener(type, fn, false) :
			el.attachEvent ?
				el.attachEvent("on" + type, fn) :
			el['on' + type] = fn;
        },
        un: function (el, type, fn) {
            el.removeEventListener ?
				el.removeEventListener(type, fn, false) :
			el.detachEvent ?
				el.detachEvent("on" + type, fn) :
			el['on' + type] = null;
        },
        evt: function (e) {
            return e || window.event;
        }
    };
    return function (opt) {
        var conf = null, defaultConf, diffX, diffY;
        function Config(opt) {
            this.target = opt.target;
            this.bridge = opt.bridge;
            this.dragable = opt.dragable != false;
            this.dragX = opt.dragX != false;
            this.dragY = opt.dragY != false;
            this.area = opt.area;
            this.scrollBar = opt.scrollBar !=false;//是否为滚动条
            this.callback = opt.callback;
        }
        function Dragdrop(opt) {
            if (!opt) { return; }
            conf = new Config(opt);
            defaultConf = new Config(opt);
            conf.bridge ?
				E.on(conf.bridge, 'mousedown', mousedown) :
				E.on(conf.target, 'mousedown', mousedown);
        }
        Dragdrop.prototype = {
            dragX: function () {
                conf.dragX = true;
                conf.dragY = false;
            },
            dragY: function (b) {
                conf.dragY = true;
                conf.dragX = false;
            },
            dragAll: function () {
                conf.dragX = true;
                conf.dragY = true;
            },
            setArea: function (a) {
                conf.area = a;
            },
            setBridge: function (b) {
                conf.bridge = b;
            },
            setDragable: function (b) {
                conf.dragable = b;
            },
            reStore: function () {
                conf = new Config(defaultConf);
                conf.target.style.top = '0px';
                conf.target.style.left = '0px';
            },
            getDragX: function () {
                return conf.dragX;
            },
            getDragY: function () {
                return conf.dragY;
            },
            setMoveToX: function (d) {
                //alert(d);
                conf.target.style.left = d + 'px';
            },
            setMoveToY: function (d) {
                //alert(d);
                conf.target.style.top = d + 'px';
            }
        }
        function mousedown(e) {
            e = E.evt(e);
            var el = conf.target;
            el.style.position = 'absolute';
            el.style.cursor = 'pointer';
            if (el.setCapture) { //IE
                E.on(el, "losecapture", mouseup);
                el.setCapture();
                e.cancelBubble = true;
            } else if (window.captureEvents) { //标准DOM
                e.stopPropagation();
                E.on(window, "blur", mouseup);
                e.preventDefault();
            }
            diffX = e.clientX - el.offsetLeft;
            diffY = e.clientY - el.offsetTop;
            E.on(doc, 'mousemove', mousemove);
            E.on(doc, 'mouseup', mouseup);
        }
        function mousemove(e) {
            var el = conf.target, e = E.evt(e), moveX = e.clientX - diffX, moveY = e.clientY - diffY;
            var minX, maxX, minY, maxY;
            if (conf.area) {
                minX = conf.area[0];
                maxX = conf.area[1];
                minY = conf.area[2];
                maxY = conf.area[3];

                moveX < minX && (moveX = minX);
                moveX > maxX && (moveX = maxX);

                moveY < minY && (moveY = minY);
                moveY > maxY && (moveY = maxY);
            }
            if (conf.dragable) {

                conf.dragX && (el.style.left = moveX + 'px');
                conf.dragY && (el.style.top = moveY + 'px');
                if (conf.callback) {
                    var obj = { moveX: moveX, moveY: moveY };
                    conf.callback.call(conf, obj);
                }
            }
        }
        function mouseup(e) {
            var el = conf.target;
            el.style.cursor = 'default';
            E.un(doc, 'mousemove', mousemove);
            E.un(doc, 'mouseup', mouseup);
            if (el.releaseCapture) { //IE
                E.un(el, "losecapture", mouseup);
                el.releaseCapture();
            }
            if (window.releaseEvents) { //标准DOM
                E.un(window, "blur", mouseup);
            }
        }
        return new Dragdrop(opt);
    }
}(this);

/* common JavaScript Function  | JQ Function 
Name:scrollBar JQplugin
function:scrollbar, DragBox, ShowFollowTips
author:vixony
CDate:20140618
Version:2.0
*/
;(function ($) {
    $.fn.extend({
        ScrollBar: function (settings) {
            var _self = this
               , setDefauls = {
                    followX: "",
                    followY: "",
                    fixPosition:"",
                    scrlEndLoad: function () { }
                }
               , opt = $.extend(setDefauls, settings)
               , $dom = $(document);
            return $(_self).each(function (i, e) {
                    
                var thisBx = this, vx_scroll = $(this), scrollObj = $.vxRandomStr,vxScrBxH,vxScrBxW,
                    
                    temObj = null, xArea = [], yArea = [], vxScrBx, xPack, yPack, temScrH, temScrW, vxFollowBX, vxFollowBY,
                    xTrack,yTrack,xTrackW,yTrackH,xTrackSW,yTrackSH,xObj,yObj,xPcent=1,yPcent=1,
                    xBar,yBar,xBarW,yBarH,yScrlH,xScrlW,scrBX,scrBY,vxFollowBX,vxFollowBY,
                    xbarPos = 0, ybarPos = 0, xscrPos = 0, yscrPos = 0,
                        scrollBoxID = vx_scroll.attr("id"),
                        scrollData = $dom.data("scrollBar_" + scrollBoxID) ;
                    
                //[1,2,3,4]xb,yb,xs,ys

              

                //造结构
                vxFollowBX = $(opt.followX + "");
                vxFollowBY = $(opt.followY + "");

                if (vx_scroll.children(".jscroll-c").height() == null) {
                    vx_scroll.wrapInner("<div class='jscroll-c' unselectable='on'></div>");
                    vx_scroll.append("<div class='jscroll-h' unselectable='on'><div class='jscroll-hp' unselectable='on'><div class='jscroll-hb'  unselectable='on'></div></div></div><div class='jscroll-v' unselectable='on'><div class='jscroll-vp'  unselectable='on'><div class='jscroll-vb'  unselectable='on'> </div></div></div>");
                };

                vxScrBx = $(".jscroll-c", vx_scroll);
                xPack = $(".jscroll-h", vx_scroll);
                yPack = $(".jscroll-v", vx_scroll);
                xTrack = $(".jscroll-hp", vx_scroll);
                yTrack = $(".jscroll-vp", vx_scroll);
                xBar = $(".jscroll-hb", vx_scroll);
                yBar = $(".jscroll-vb", vx_scroll);

                function setScrolBox() {
                    if (scrollData == undefined || opt.fixPosition == "") {
                        $dom.data("scrollBar_" + scrollBoxID, [0, 0, 0, 0]);
                    }
                    //内容滚动区域
                    vxScrBxH = vxScrBx.height();
                    vxScrBxW = vxScrBx.width();
                    temScrH = vxScrBx[0].scrollHeight;
                    temScrW = vxScrBx[0].scrollWidth;

                    //滚动条尺寸
                    xTrackSW = vxScrBxW - 11;
                    yTrackSH = vxScrBxW - 11;
                    if (temScrH > vxScrBxH) {   //垂直有滚动
                        yScrlH = temScrH;
                        xTrackSW = vxScrBxW - 11;
                        yTrack.css({ "visibility": "visible" });
                    } else {                    //垂直无滚动
                        yScrlH = vxScrBxH;
                        xTrackSW = vxScrBxW;
                        yTrack.css({ "visibility": "hidden" });
                    }
                    

                    if (temScrW > vxScrBxW) {   //水平有滚动
                        xScrlW = temScrW;
                        yTrackSH = vxScrBxH - 11;
                        xTrack.css({ "visibility": "visible" });
                    } else {                    //水平无滚动
                        xScrlW = vxScrBxW;
                        yTrackSH = vxScrBxH;
                        xTrack.css({ "visibility": "hidden" });
                    }
                    xTrack.width(xTrackSW);
                    yTrack.height(yTrackSH);


                    //滚动滑块尺寸
                    xBarW = xTrackSW * vxScrBxW / xScrlW;
                    yBarH = yTrackSH * vxScrBxH / yScrlH;

                    xBarW = xBarW < 40 ? 40 : xBarW;
                    yBarH = yBarH < 40 ? 40 : yBarH;

                    xBar.width(xBarW);
                    yBar.height(yBarH);

                    //滚动控制比例
                    xPcent = (xScrlW > vxScrBxW) ? ((xScrlW - vxScrBxW) / (xTrackSW - xBarW)) : 1;
                    yPcent = (yScrlH > vxScrBxH) ? ((yScrlH - vxScrBxH) / (yTrackSH - yBarH)) : 1;

                    //滚动位置控制

                    if (opt.fixPosition == "sort") {
                        vxScrBx[0].scrollLeft = scrollData[1];
                        vxScrBx[0].scrollTop = scrollData[3];
                        (vxFollowBX.length>0) && (vxFollowBX[0].scrollLeft = scrollData[1]);
                        (vxFollowBY.length>0) && (vxFollowBY[0].scrollTop = scrollData[3]);
                    }
                                                            
                    xscrPos = vxScrBx[0].scrollLeft;
                    yscrPos = vxScrBx[0].scrollTop;

                    xbarPos = xscrPos / xPcent;
                    ybarPos = yscrPos / yPcent;

                    xBar.css("left", xbarPos + "px");
                    yBar.css("top", ybarPos + "px");

                    xArea = [0, xTrackSW - xBarW, 0, 0];
                    yArea = [0, 0, 0, yTrackSH - yBarH];
                }
                setScrolBox();

                function setXMove() {
                    xBar.css({ left: xbarPos + "px" });
                    xscrPos = xbarPos * xPcent;
                    vxScrBx[0].scrollLeft = xscrPos;
                    if (vxFollowBX.length != 0) {
                        vxFollowBX[0].scrollLeft = xscrPos;
                    }

                    //记录位置x
                    $dom.data("scrollBar_" + scrollBoxID)[0] = xbarPos;
                    $dom.data("scrollBar_" + scrollBoxID)[1] = xscrPos;
                }
                function setYMove() {
                    yBar.css({ top: ybarPos + "px" });
                    yscrPos = ybarPos * yPcent;
                    vxScrBx[0].scrollTop = yscrPos;
                    if (vxFollowBY.length != 0) {
                        vxFollowBY[0].scrollTop = yscrPos;
                    }

                    //记录位置y
                    $dom.data("scrollBar_" + scrollBoxID)[2] = ybarPos;
                    $dom.data("scrollBar_" + scrollBoxID)[3] = yscrPos;
                }
                scrBX = new Dragdrop({
                    target: xBar[0],
                    area: xArea,
                    dragX: true,
                    dragY: false,
                    callback: function (obj) {
                        var scrlDx = obj.moveX * xPcent;
                            xbarPos = obj.moveX;
                            xscrPos = scrlDx;
                            vxScrBx[0].scrollLeft = scrlDx;
                            if (vxFollowBX.length != 0) {
                                vxFollowBX[0].scrollLeft = scrlDx;
                            }
                        //记录位置x
                            $dom.data("scrollBar_" + scrollBoxID)[0] = xbarPos;
                            $dom.data("scrollBar_" + scrollBoxID)[1] = xscrPos;
                    }
                });
                scrBY = new Dragdrop({
                    target: yBar[0],
                    area: yArea,
                    dragX: false,
                    dragY: true,
                    callback: function (obj) {
                        var scrlDy = obj.moveY * yPcent;
                            ybarPos = obj.moveY;
                            yscrPos = scrlDy;
                            vxScrBx[0].scrollTop = scrlDy;
                            if (vxFollowBY.length != 0) {
                                vxFollowBY[0].scrollTop = scrlDy;
                            }
                        //记录位置y
                            $dom.data("scrollBar_" + scrollBoxID)[2] = ybarPos;
                            $dom.data("scrollBar_" + scrollBoxID)[3] = yscrPos;
                    }
                });
                this.resetScroll = function (sort) {
                    (sort == "sort") ? (opt.fixPosition = "sort") : (opt.fixPosition = "");
                    setScrolBox();
                    scrBX.setArea(xArea);
                    scrBY.setArea(yArea);
                }

                //点击轨道
                xTrack.unbind("mousedown").mousedown(function (evt) {
                    var xPosition = evt.pageX - xBar.offset().left;
                    xbarPos = xPosition > 0 ? (xbarPos + xPosition - xBarW) : (xbarPos + xPosition);

                    setXMove();
                    evt.stopPropagation();
                    evt.preventDefault();
                    return false;
                });
                yTrack.mousedown(function (evt) {
                    var yPosition = evt.pageY - yBar.offset().top;
                    ybarPos = yPosition > 0 ? (ybarPos + yPosition - yBarH) : (ybarPos + yPosition);
                    setYMove();
                    evt.stopPropagation();
                    evt.preventDefault();
                    return false;
                });
                vx_scroll.mousewheel(function (event, delta) {
                    if (yTrack.css("display") == "none") return;
                    if (delta > 0) { ybarPos -= (50 / yPcent); } else { ybarPos += (50 / yPcent); };
                    ybarPos = (ybarPos <= 0) ? 0 : (ybarPos > (yTrackSH - yBarH) ? (yTrackSH - yBarH) : ybarPos);
                    setYMove();
                    event.stopPropagation();
                    event.preventDefault();
                    return false;
                });
                vx_scroll.mouseenter(function (evt) {
                    $(this).addClass("vxover");
                    vx_scroll.unbind("mousemove").mousemove(function () {
                        vx_scroll.addClass("vxover");
                    });
                    $(this).attr("tabindex", 0).attr("hidefocus", "true").focus().keydown(function (evt) {
                        evt = evt || window.event;
                        var theKey = evt.keyCode;
                        if (theKey == 37) {//left
                            xbarPos -= (75 / xPcent);
                            xbarPos = (xbarPos <= 0) ? 0 : xbarPos;
                            setXMove();
                            evt.stopPropagation();
                            evt.preventDefault();
                            return false;
                        } else if (theKey == 39) {//right
                            xbarPos += (75 / xPcent);
                            xbarPos = xbarPos > (xTrackSW - xBarW) ? (xTrackSW - xBarW) : xbarPos;
                            setXMove();
                            evt.stopPropagation();
                            evt.preventDefault();
                            return false;
                        } else if (theKey == 38) {//UP
                            ybarPos -= (75 / yPcent);
                            ybarPos = (ybarPos <= 0) ? 0 : ybarPos;
                            setYMove();
                            evt.stopPropagation();
                            evt.preventDefault();
                            return false;
                        } else if (theKey == 40) {//DOWN
                            ybarPos += (75 / yPcent);
                            ybarPos = ybarPos > (yTrackSH - yBarH) ? (yTrackSH - yBarH) : ybarPos;
                            setYMove();
                            evt.stopPropagation();
                            evt.preventDefault();
                            return false;
                        } else if (theKey == 36) {//home
                            ybarPos = 0;
                            setYMove();
                            evt.stopPropagation();
                            evt.preventDefault();
                            return false;
                        } else if (theKey == 35) {//end
                            ybarPos = yTrackSH - yBarH;
                            setYMove();
                        } else if (theKey == 33) {//pageup
                            ybarPos -= vxScrBxH / yPcent;
                            ybarPos = (ybarPos <= 0) ? 0 : ybarPos;
                            setYMove();
                            evt.stopPropagation();
                            evt.preventDefault();
                            return false;
                        } else if (theKey == 34) {//pagedown
                            ybarPos += vxScrBxH / yPcent;
                            ybarPos = ybarPos > (yTrackSH - yBarH) ? (yTrackSH - yBarH) : ybarPos;
                            setYMove();
                            evt.stopPropagation();
                            evt.preventDefault();
                            return false;
                        }
                    })
                 .mouseleave(function () {
                     $(this).mouseup(function () {
                         $(this).removeClass("vxover");
                         vx_scroll.unbind("mouseup");
                     });
                     $(this).removeClass("vxover");
                     $(this).unbind("keydown");
                 })
                    ;
                });
            });
        }
        , DragBox: function () {
            return $(this).each(function (idx, elm) {
                var drgbx = $(elm), drgbar = $(".dragBar", elm),
                    drgbxWidth = drgbx.outerWidth(true),
                    drgbxHeight = drgbx.outerHeight(true),
                    thisDrag = new Dragdrop({
                         target: elm,
                         bridge:drgbar[0],
                         area: [0, ($.win().w - drgbxWidth), 0, ($.win().h - drgbxHeight)],
                         dragX: true,
                         dragY: true,
                         callback: function (obj) {}
                    });
                $(".closeBx",elm).click(function () { drgbx.hide(); })
                $(window).resize(function () {
                    var drgbxTop = parseInt(drgbx.css("top")),
                        drgbxLeft = parseInt(drgbx.css("left")),
                        drgAreaW = $.win().w - drgbxWidth,
                        drgAreaH = $.win().h - drgbxHeight;

                    if (drgbxTop > drgAreaH) { drgbx.css({ "top": ((drgAreaH<=0)?0:drgAreaH)  + "px" }) }
                    if (drgbxLeft > drgAreaW) { drgbx.css({ "left": ((drgAreaW<=0)?0:drgAreaW)  + "px" }) }
                    thisDrag.setArea([0, drgAreaW, 0, drgAreaH]);
                });
            });
         }
       , ShowFollowTips: function (settings) {
           var options = {
                  tipopbox: "",
                  callbacks: function () { }
              };
          options = $.extend(options, settings);
          var _self = this,
             tiPoint = $(_self);
          if (options.tipopbox != "") {
              var tiPopBx = $(options.tipopbox + ""),
                  datshowbx = $(".t_i", tiPopBx).html("");
              tiPoint.each(function (idx, elm) {
                  var $elm = $(elm);
                  $elm.mouseover(function (evt) {
                   datshowbx.html("");
                   var showdata = $elm.attr("data-value");
                   if (showdata != undefined && showdata != "") {
                       datshowbx.html(showdata);
                   }
                   var cur_p = $.mousePos(evt), p_x = cur_p.x, p_y = cur_p.y
                   thisH = $(this).outerHeight(true),
                   thisW = $(this).outerWidth(true),
                   thisLeft = $(this).offset().left,
                   thisTop = $(this).offset().top,
                   tipsH = tiPopBx.outerHeight(true),
                   tipsW = tiPopBx.outerWidth(true),
                   tipsTop = thisTop + thisH,
                   tipsLeft = thisLeft - tipsW/2 + thisW/2;
                       
                   if ((thisTop + tipsH) > $.win().h) {
                       tiPopBx.addClass("up");
                       tipsTop = thisTop - tipsH;
                   } else {
                       tiPopBx.removeClass("up");
                   }
                   tiPopBx.css({ "left": tipsLeft + "px", "top": tipsTop + "px" }).stop(true, false).fadeTo(200, 1);
               }).mouseleave(function () {
                   tiPopBx.stop(true, false).delay(400).fadeTo(300, 0).hide();
               });
              });
              tiPopBx.mouseover(function () { $(this).stop(true, false).fadeTo(0, 1) }).mouseleave(function () {
                   $(this).stop(true, false).fadeTo(100, 0).hide();
               });
          }
       }
        , ShowPopTips: function (settings) {
            var options = {
                tipopbox: "",
                tipevent: "click",//hover
                tipdatype: "url",//tval
                callbacks: function () { }
            },
            opType = {
                "click": "click"
                , "hover": "mouseover"
                , "url": "data-url"
                , "tval": "data-tval"
            };
            options = $.extend(options, settings);
            options.tipevent = (opType[options.tipevent + ""] == undefined) ? "click" : options.tipevent + "";
            options.tipdatype = (opType[options.tipdatype + ""] == undefined) ? "tval" : options.tipdatype + "";

            var _self = this,
               tiPoint = $(_self);
           if (options.tipopbox != "") {
               var tiPopBx = $(options.tipopbox + ""),
                   datshowbx = $(".t_i", tiPopBx).html("");
                tiPoint.each(function (idx, elm) {
                       var $elm = $(elm);
 
                    $elm.bind(opType[options.tipevent + ""], function (evt) {
                           datshowbx.html("数据加载中……");
                           var dataUrl = $elm.attr("data-url"),
                               dataVal = $elm.data("data-value"),
                               cur_p = $.mousePos(evt), p_x = cur_p.x, p_y = cur_p.y,
                               thisH = $(this).outerHeight(true),
                               thisW = $(this).outerWidth(true),
                               thisLeft = $(this).offset().left,
                               thisTop = $(this).offset().top,
                               tipsH = tiPopBx.outerHeight(true),
                               tipsW = tiPopBx.outerWidth(true),
                               tipsTop = thisTop + thisH,
                               tipsLeft = thisLeft - tipsW / 2 + thisW / 2;
                           function SetPosition() {
                               tipsH = tiPopBx.outerHeight(true),
                               tipsW = tiPopBx.outerWidth(true),
                               tipsTop = thisTop + thisH,
                               tipsLeft = thisLeft - tipsW / 2 + thisW / 2;
                             
                               if ((thisTop + tipsH) > $.win().h) {
                                   tiPopBx.addClass("up");
                                   tipsTop = thisTop - tipsH;
                               } else {
                                   tiPopBx.removeClass("up");
                               }
                               tiPopBx.css({ "left": tipsLeft + "px", "top": tipsTop + "px" }).stop(true, false).fadeTo(200, 1);
                           };
                           SetPosition();
                           if (options.tipdatype + "" === "url") {
                               dataUrl = $elm.attr("data-url");
                               dataVal = $elm.data("data-value");

                               if (dataVal == undefined || dataVal == "") {
                                   $.ajax({
                                       url: dataUrl //
                                       , success: function (datsrt) {
                                           $elm.data("data-value", datsrt);
                                           datshowbx.html("<div class='tipTb'>" + datsrt + "</div>");
                                           SetPosition();
                                       }
                                       , error: function () {
                                           datshowbx.html("<div class='tipTb'>  数据加载失败 ！</div>");
                                           SetPosition();
                                       }
                                   });
                               } else {
                                   datshowbx.html("<div class='tipTb'>" + dataVal + "</div>");
                                   SetPosition();
                               }
                           } else {
                               dataVal = $elm.attr("data-tval");
                               if (dataVal == undefined || dataVal == "") {
                                   datshowbx.html("<div class='tipTb'> 数据资料尚在整理中，请稍后再试！</div>");
                                   SetPosition();
                               } else {
                                   datshowbx.html("<div class='tipTb'>" + dataVal + "</div>");
                                   SetPosition();
                               }
                           }
                      }).mouseleave(function () {
                           tiPopBx.stop(true, false).delay(400).fadeTo(300, 0).hide();
                       });
                });
                tiPopBx.mouseenter(function () { $(this).stop(true, false).fadeTo(0, 1) }).mouseout(function () {
                    $(this).stop(true, false).fadeTo(1, 0).hide();
                });
           }
       }
    });
})(jQuery);





